using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;

namespace Bamboo.Core.Common.Crypto
{
    public class CryptoUtil
    {
        public static string EncryptMD5(string value)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] byteValue = System.Text.Encoding.UTF8.GetBytes(value);
            byte[] byteHash = md5.ComputeHash(byteValue);

            return Convert.ToBase64String(byteHash);
        }


        public static byte[] EncryptSHA1(string text)
        {
            SHA1 sha1 = SHA1.Create();
            UTF8Encoding encoding = new UTF8Encoding();
            return sha1.ComputeHash(encoding.GetBytes(text));
        }

        public static byte[] EncryptSHA256(string text)
        {
            SHA256 sha256 = SHA256.Create();
            UTF8Encoding encoding = new UTF8Encoding();
            return sha256.ComputeHash(encoding.GetBytes(text));
        }
    }
}
